package chapter3.No3_1_等待和通知机制.a不使用等待通知机制实现线程间通信;

/**
 * Created by Administrator on 2016/11/16.
 */
public class ThreadA extends Thread {
    ServiceClass sc;

    public ThreadA(ServiceClass sc) {
        this.sc = sc;
    }

    @Override
    public void run() {
        for(int i = 0; i < 10; i++) {
            try {
                Thread.sleep(500);
                sc.add();
                System.out.println("添加了"+(i+1)+"个元素");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
